package com.yaorange.nongjt.certificate.service.impl;

import com.yaorange.nongjt.certificate.domain.NjtYtjPos;
import com.yaorange.nongjt.certificate.mapper.NjtYtjPosMapper;
import com.yaorange.nongjt.certificate.service.INjtPosService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collections;
import java.util.List;

/**
 * @author coach tam
 * @email 327395128@qq.com
 * @values 坚持灵活 灵活坚持
 * @since 2024/10/10
 */
@Service
public class NjtPosServiceImpl implements INjtPosService {

    @Autowired
    private NjtYtjPosMapper njtYtjPosMapper;

    @Override
    @Transactional(readOnly = true)
    public List<NjtYtjPos> selectPosList(NjtYtjPos pos) {
        return njtYtjPosMapper.selectPosList(pos);
    }

    @Override
    @Transactional(
            rollbackFor = Exception.class,
            isolation = Isolation.REPEATABLE_READ,
            propagation = Propagation.REQUIRED,
            timeout = 10,
            readOnly = false
    )
    public int insertPos(NjtYtjPos njtYtjPos) {
        return njtYtjPosMapper.insertPos(njtYtjPos);
    }

    @Override
    public int updatePos(NjtYtjPos njtYtjPos) {
        return njtYtjPosMapper.updatePos(njtYtjPos);
    }

    @Override
    /*@Transactional*/
    public int deletePos(Long[] ids) {
        /*for (int i = 0; i < ids.length; i++) {
            njtYtjPosMapper.deleteById(ids[i]);
        }*/
        return njtYtjPosMapper.deleteByIds(ids);
    }

    /*   @Transactional(propagation = Propagation.REQUIRES_NEW)
    public void test1() {

    }*/
}
